<template>
  <div>
    <!--    <div class="pb20 pt10">-->
    <!--      <el-button size="mini" @click="handleToNew" icon="el-icon-plus" type="primary">新建退货地址</el-button>-->
    <!--    </div>-->
    <c-u-r-d-table :option="option"/>
  </div>
</template>

<script>
import {merchantReturnAddressApi} from "@/feature/mct/infra/api/merchantReturnAddressApi";
import CURDTable from "@/framework/components/table/CURDTable";
import ColumnType from "@/framework/constant/ColumnType";
import YesNoEnum from "@/infra/constant/YesNoEnum";

export default {
  name: "returnAddressTable",
  components: {CURDTable},
  data() {
    return {
      option: {
        requestApi: merchantReturnAddressApi,
        pagination: false,
        dialogWidth: '600px',
        showSelection: false,
        columns: [
          {
            label: '收件人',
            required: true,
            width: 'auto',
            span: 24,
            prop: 'username'
          },
          // {
          //   label: '是否默认地址',
          //   prop: 'defaultFlag',
          //   type: ColumnType.RADIO,
          //   options: YesNoEnum
          // },
          {
            label: '手机号',
            width: 'auto',
            required: true,
            span: 24,
            prop: 'telephone'
          },
          {
            label: '所在地区',
            span: 24,
            width: 'auto',
            type: ColumnType.ADDRESS,
            required: true,
            prop: 'fullRegion'
          },
          {
            label: '详细地址',
            span: 24,
            required: true,
            type: ColumnType.TEXTAREA,
            width: 'auto',
            prop: 'detailAddress'
          },
          {
            label: '是否默认地址',
            span: 24,
            required: true,
            options: YesNoEnum,
            type: ColumnType.RADIO,
            defaultValue: 0,
            width: 'auto',
            prop: 'defaultFlag'
          }
        ]
      }
    }
  },
  created() {
    this.loadData()
  },
  methods: {
    loadData() {

    },
    handleSetAsDefault({arg,$service}) {
      merchantReturnAddressApi.setAsDefault(arg.id).then(() => {
        this.$message.success('设置默认成功')
        $service.reloadTable()
      })
    }
  }
}
</script>

<style scoped>

</style>
